package com.doctor.utils.storage;

import android.content.Context;
import android.content.SharedPreferences;

import com.doctor.constants.ShareConfig;

/**
 * Created by nieyunlong
 * 用户操作
 * on 2016/9/22.
 */
public class SharePreferenceUtil {

    /**
     * 设置登录状态
     *
     * @param context
     * @param isLogin
     */
    public static void setLoginState(Context context, boolean isLogin) {
        SharedPreferences isLoginInSharedpreference = getIsLoginInSharedpreference(context);
        if (isLoginInSharedpreference != null) {
            SharedPreferences.Editor isLoginEditor = isLoginInSharedpreference.edit();
            isLoginEditor.putBoolean(ShareConfig.IS_LOGIN, isLogin);
            isLoginEditor.clear();
            isLoginEditor.commit();
        }
    }


    /**
     * @return返回本地存储的是否登录的sp
     */
    public static SharedPreferences getIsLoginInSharedpreference(Context context) {
        if (context != null) {
            return context.getSharedPreferences(ShareConfig.IS_LOGIN, Context.MODE_PRIVATE);
        }
        return null;
    }




}
